import sys
import jieba


def jieba_parallel_cut():
    txt_fp, save_fp, cpu_count = sys.argv[1], sys.argv[2], int(sys.argv[3])
    jieba.enable_parallel(cpu_count)
    print('Reading txt dataset..')
    content = open(txt_fp, 'rb').read()
    print('Cutting text..')
    words = ' '.join(jieba.cut(content))
    log_f = open(save_fp, 'w')
    log_f.write(words)
    jieba.disable_parallel()


if __name__ == '__main__':
    jieba_parallel_cut()
